﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using nplJobsCommon.Common;
using nplJobsCommon.Employeer;

namespace nplJobsDAL.Select
{
    public class SelectEmployeeRange : DataAccessBase
    {
        public SelectEmployeeRange()
        {
            StoredProcedureName = StoredProcedure.Name.spSelectEmployeeRange.ToString();
        }

        #region GetEmployeeRange
        public List<EmployeeRange> GetEmployeeRange()
        {
            DataBaseHelper dbHelper;
            DataSet dsEmployeeRange;

            try
            {
                dbHelper = new DataBaseHelper(StoredProcedureName);
                dsEmployeeRange = dbHelper.Run(base.ConnectionString);
                return GetList(dsEmployeeRange);
            }
            catch (Exception)
            {

                throw;
            }
        }
        #endregion

        #region GetList
        private List<EmployeeRange> GetList(DataSet dsEmployeeRange)
        {
            List<EmployeeRange> employeeranges;
            try
            {
                employeeranges = (from n in dsEmployeeRange.Tables[0].AsEnumerable()
                                  select new EmployeeRange
                                   {
                                       ID = n.Field<int>("ID"),
                                       Range = n.Field<string>("Range")
                                   }).ToList();

                return employeeranges;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
            finally { }
        }
        #endregion
    }
}


